---
title: "Border Color"
description: "Utilities for controlling the color of an element's borders."
features:
  responsive: true
  customizable: true
  hover: true
  focus: false
---

import plugin from 'tailwindcss/lib/plugins/borderColor'
import { Variants } from '@/components/Variants'
import { Disabling } from '@/components/Disabling'
import { Heading } from '@/components/Heading'

export const classes = {
  plugin,
  preview: (css, { className }) => (
    <td className={`relative w-16 p-2 font-mono text-xs whitespace-pre ${className}`}>
      <div
        className="absolute inset-0 m-2 border"
        style={{
          borderColor: Array.isArray(css['border-color'])
            ? css['border-color'][0]
            : css['border-color'],
        }}
      />
    </td>
  ),
}

## Usage

Control the border color of an element using the `border-{color}` utilities.

```html rose
<template preview>
  <div class="max-w-xs w-full mx-auto">
    <input class="border border-red-500 bg-white text-gray-900 appearance-none block w-full rounded-md py-3 px-4 focus:outline-none" placeholder="Your email">
  </div>
</template>

<input class="border-2 **border-red-500** ...">
```

### Changing opacity

Control the opacity of an element's border color using the `border-opacity-{amount}` utilities.

```html lightBlue
<template preview>
  <div class="grid grid-cols-2 gap-2 sm:grid-cols-5">
    <div class="h-16 flex-1 rounded border-4 border-light-blue-500 border-opacity-100 font-extrabold text-light-blue-600 flex justify-center items-center">100%</div>
    <div class="h-16 flex-1 rounded border-4 border-light-blue-500 border-opacity-75 font-extrabold text-light-blue-600 flex justify-center items-center">75%</div>
    <div class="h-16 flex-1 rounded border-4 border-light-blue-500 border-opacity-50 font-extrabold text-light-blue-600 flex justify-center items-center">50%</div>
    <div class="h-16 flex-1 rounded border-4 border-light-blue-500 border-opacity-25 font-extrabold text-light-blue-600 flex justify-center items-center">25%</div>
    <div class="h-16 flex-1 rounded border-4 border-light-blue-500 border-opacity-0 font-extrabold text-light-blue-600 flex justify-center items-center">0%</div>
  </div>
</template>

<div class="border-4 border-light-blue-500 **border-opacity-100** ..."></div>
<div class="border-4 border-light-blue-500 **border-opacity-75** ..."></div>
<div class="border-4 border-light-blue-500 **border-opacity-50** ..."></div>
<div class="border-4 border-light-blue-500 **border-opacity-25** ..."></div>
<div class="border-4 border-light-blue-500 **border-opacity-0** ..."></div>
```

Learn more in the [border opacity documentation](/docs/border-opacity).

## Responsive

To control the border color of an element at a specific breakpoint, add a `{screen}:` prefix to any existing border color utility. For example, use `md:border-green-500` to apply the `border-green-500` utility at only medium screen sizes and above.

```html
<button class="border-blue-500 **md:border-green-500** ...">
  Button
</button>
```

For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation.

## Hover

To control the border color of an element on hover, add the `hover:` prefix to any existing border color utility. For example, use `hover:border-blue-500` to apply the `border-blue-500` utility on hover.

```html purple
<template preview>
  <div class="flex items-center justify-center">
    <button class="border-2 border-purple-500 hover:border-gray-500 bg-transparent text-purple-700 hover:text-gray-700 py-3 px-4 font-semibold rounded-md">
      Button
    </button>
  </div>
</template>

<button class="border-2 border-purple-500 **hover:border-gray-500** ...">
  Button
</button>
```

Hover utilities can also be combined with responsive utilities by adding the responsive `{screen}:` prefix *before* the `hover:` prefix.

```html
<button class="... md:border-blue-500 md:hover:border-blue-700 ...">Button</button>
```

## Focus

To control the border color of an element on focus, add the `focus:` prefix to any existing border color utility. For example, use `focus:border-blue-500` to apply the `border-blue-500` utility on focus.

```html blue
<template preview>
  <div class="max-w-xs w-full mx-auto">
    <input class="border border-gray-300 bg-white text-gray-900 appearance-none block w-full rounded-md py-3 px-4 focus:border-blue-500 focus:outline-none" placeholder="Your email">
  </div>
</template>

<input class="border border-red-500 focus:border-blue-500 ...">
```

Focus utilities can also be combined with responsive utilities by adding the responsive `{screen}:` prefix *before* the `focus:` prefix.

```html
<input class="... md:border-gray-200 md:focus:border-white ...">
```

---

## Customizing

### Border Colors

By default, Tailwind makes the entire [default color palette](/docs/customizing-colors#default-color-palette) available as border colors.

You can [customize your color palette](/docs/colors#customizing) by editing the `theme.colors` section of your `tailwind.config.js` file, or customize just your border colors using the `theme.borderColor` section.

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      borderColor: theme => ({
-       ...theme('colors'),
        DEFAULT: theme('colors.gray.300', 'currentColor'),
+       'primary': '#3490dc',
+       'secondary': '#ffed4a',
+       'danger': '#e3342f',
      })
    }
  }
```

### Variants

<Variants plugin="borderColor" />

### Disabling

<Disabling plugin="borderColor" />
